#include <iostream>

class Singleton
{
	public:
		static Singleton* getInstance(void);
	private:
		virtual ~Singleton(void){}
		Singleton(){}
		Singleton(const Singleton&){}
		Singleton& operator=(const Singleton&);
		class Garbo
		{
			public:
				~Garbo(void)
				{
					if(Singleton::instance)
					{
						delete Singleton::instance;
						Singleton::instance = NULL;
					}
				}
		};
		static Garbo garbo;
		static Singleton* instance;
};


Singleton* Singleton::getInstance(void)
{
	if(NULL == instance)
	{
		instance = new Singleton();
	}
	return instance;
}
/*
Singleton::~Singleton()
{
	if(NULL == instance)
	{
		return;
	}
	delete instance;
}
*/
Singleton * Singleton::instance = NULL;

int main(int argc, char **argv)
{
	Singleton * instance = Singleton::getInstance();
	return 0;
}
